# define depends jarfiles name
libpath = './lib/'
api = libpath + 'appengine-api-1.0-sdk-1.3.0.jar'
labs = libpath + 'appengine-api-labs-1.3.0.jar'
stub = libpath + 'appengine-api-stubs.jar'
localruntime = libpath + 'appengine-local-runtime.jar'
tools = libpath + 'appengine-tools-api.jar'
balmysundaycandycore = libpath + 'balmysundaycandy-core.jar'
balmysundaycandymll = libpath + 'balmysundaycandy-morelowlevel-sdk1.3.0.jar'

# load? jarfiles
require api
require labs
require stub
require localruntime
require tools
require balmysundaycandycore
require balmysundaycandymll

# setup tool environment
config = Java::balmysundaycandy.core.test.EnvironmentConfiguration.new('',false,false)
puts config
envutils = Java::balmysundaycandy.core.test.TestEnvironmentUtils
envutils.setupEnvironment(config)

# call appengine api rawly 
apiproxy = Java::com.google.apphosting.api.ApiProxy
byte = "this is sample byte".unpack("C*")
result = apiproxy.makeSyncCall('datastore_v3','Get', byte.to_java(:byte))
puts result

# not work com.google.storage.onestore.v3.OnestoreAction.Action cause java.lang.NoClassDefFoundError
getresponse = Java::com.google.apphosting.api.DatastorePb.GetResponse
#getpb = getresponse.new
#getpb.margeFrom(result)
#puts getpb

# call appengine api via balmysundaycandy, but not work com.google.storage.onestore.v3.OnestoreAction.Action cause java.lang.NoClassDefFoundError
# datastore = Java::balmysundaycandy.more.low.level.operations.datastore.DatastoreOperations
# getrequest = Java::com.google.apphosting.api.DatastorePb.GetRequest
# getresponse = datastore.GET.call(getrequest.new)
# puts getresponse

# teardownd environment
envutils.teardownEnvironment(config)
